package com.example.makerspace.dao;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.makerspace.domain.CompetitionChangeRecordDO;
import com.example.makerspace.domain.EnterpriseCertificationDO;
import com.example.makerspace.mapper.CompetitionChangeRecordMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component
public class CompetitionChangeRecordDAO  extends  BaseDAO<CompetitionChangeRecordDO> {
    @Resource
    private CompetitionChangeRecordMapper competitionChangeRecordMapper;
    @PostConstruct
    public void init(){
        this.mapper = competitionChangeRecordMapper;
    }

    public List<CompetitionChangeRecordDO> selectByCompetitionId(Integer competitionId) {
        return  mapper.selectList(new QueryWrapper<CompetitionChangeRecordDO>().eq("competition_id",competitionId));
    }

    public void deleteByUsername(String username) {
        mapper.delete(new QueryWrapper<CompetitionChangeRecordDO>().eq("username",username));
    }

    public List<CompetitionChangeRecordDO> selectByCompetitionIdAndUsername(Integer competitionId, String username) {
        return  mapper.selectList(new QueryWrapper<CompetitionChangeRecordDO>().eq("competition_id",competitionId).eq("username",username));
    }
}
